package com.whoami.idmagic.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author tzp
 * @since 2022/7/16
 */
public class HBaseReadWriteTest {
    static final String TABLE_NAME = "default:dataeco-test";
    static final String CF_DEFAULT = "c";

    public static void main(String[] args) throws IOException {
        Configuration conf = new Configuration();
        conf.set("hbase.zookeeper.quorum", "jourm01.safe.lycc.qihoo.net,jourm02.safe.lycc.qihoo.net,jourm03.safe.lycc.qihoo.net,jourm04.safe.lycc.qihoo.net,jourm05.safe.lycc.qihoo.net");
        conf.setInt("hbase.zookeeper.property.clientPort", 2181);
        conf.set("zookeeper.znode.parent", "/hbase2");

        Connection connection = ConnectionFactory.createConnection(conf);
        TableName tableName = TableName.valueOf(TABLE_NAME);
        Table table = connection.getTable(tableName);
        Result result = table.get(new Get("UR1234123412341234111".getBytes(StandardCharsets.UTF_8)));
        System.out.println(result);
    }
}
